package com.cheng.dreams.greatlydreams.ui.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;

import com.cheng.dreams.greatlydreams.R;
import com.cheng.dreams.greatlydreams.view.CalendarView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {


    @BindView(R.id.calendarview)
    CalendarView mCalendarView;
    List<String> mDatas = new ArrayList<>();
    @BindView(R.id.calendarviewtwo)
    CalendarView calendarviewtwo;
    @BindView(R.id.calendarviewThree)
    CalendarView calendarviewThree;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        mCalendarView.setClickable(true);
        // 设置点击事件
        mCalendarView.setOnClickDate(new CalendarView.OnClickListener() {
            @Override
            public void onClickDateListener(int year, int month, int day) {
//                Toast.makeText(getApplication(), year + "年" + month + "月" + day + "天", Toast.LENGTH_SHORT).show();
                // 获取已选择日期
                List<String> dates = mCalendarView.getSelectedDates();
                for (String date : dates) {
                    Log.e("test", "date: " + date);
                }
            }
        });

        calendarviewtwo.setClickable(true);
        // 设置点击事件
        calendarviewtwo.setOnClickDate(new CalendarView.OnClickListener() {
            @Override
            public void onClickDateListener(int year, int month, int day) {
                Toast.makeText(getApplication(), year + "年" + month + "月" + day + "天", Toast.LENGTH_SHORT).show();

                // 获取已选择日期
                List<String> dates = mCalendarView.getSelectedDates();
                for (String date : dates) {
                    Log.e("test", "date: " + date);
                }
            }
        });

        calendarviewThree.setClickable(true);
        // 设置点击事件
        calendarviewThree.setOnClickDate(new CalendarView.OnClickListener() {
            @Override
            public void onClickDateListener(int year, int month, int day) {
                Toast.makeText(getApplication(), year + "年" + month + "月" + day, Toast.LENGTH_SHORT).show();

                // 获取已选择日期
                List<String> dates = mCalendarView.getSelectedDates();
                for (String date : dates) {
                    Log.e("test", "date: " + date);
                }
            }
        });
        calendarviewtwo.setNextMonth();
        calendarviewThree.setNextMonth();
        calendarviewThree.setNextMonth();
    }

    private void initData() {
        mDatas.add("20170424");
        mDatas.add("20170425");
        mDatas.add("20170426");
        mDatas.add("20170427");
        mDatas.add("20170427");
        mDatas.add("20170429");
        mDatas.add("20170430");
    }

}
